package com.newtouch.bxzs.enterprise.controller;

import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;
import com.newtouch.bxzs.enterprise.config.MyLog;
import com.newtouch.bxzs.enterprise.model.bo.EnterpriseCustomerBO;
import com.newtouch.bxzs.enterprise.model.bo.EnterpriseCustomerGroupBO;
import com.newtouch.bxzs.enterprise.model.vo.EnterpriseCustomerGroupVO;
import com.newtouch.bxzs.enterprise.model.vo.EnterpriseCustomerVO;
import com.newtouch.bxzs.enterprise.service.EnterpriseCustomerGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 企业客户分组管理controller
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/2/4 11:01</td>
 * <td>dingqianbin</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author dingqianbin
 * @version 1.0.0
 * @since 1.0.0
 */
@Api(tags = "企业客户分组管理")
@RestController
@RequestMapping(value = "/enterpriseCustomerGroupController")
@SuppressWarnings("unchecked")
public class EnterpriseCustomerGroupController {

    @Autowired
    private EnterpriseCustomerGroupService enterpriseCustomerGroupService;

    /**
     * 静态变量：系统日志
     */
    private static final Log logger = LogFactory.getLog(PersonalCustomerController.class);

    @ApiOperation(value = "获取企业客户分组列表信息")
    @GetMapping("/getCustomerGroupList")
    @MyLog(systemFunctionName = "企业客户分组管理", systemFunctionUrl = "/enterpriseCustomerGroupController/getCustomerGroupList", userOperationType = 4, userOperationSummary = "获取企业客户分组列表信息")
    public BaseResponse<List<EnterpriseCustomerGroupBO>> getCustomerList() {
        logger.info("获取企业客户分组列表信息");
        return RespGenerator.returnOK(enterpriseCustomerGroupService.getGroupList());
    }

    @ApiOperation(value = "增加/修改企业客户分组信息")
    @PostMapping("/modifyEnterpriseCustomerGroup")
    @MyLog(systemFunctionName = "企业客户分组管理", systemFunctionUrl = "/enterpriseCustomerGroupController/modifyEnterpriseCustomerGroup", userOperationType = 5, userOperationSummary = "增加/修改企业客户分组信息")
    public BaseResponse<Integer> modifyEnterpriseCustomerGroup(@RequestBody EnterpriseCustomerGroupVO enterpriseCustomerGroupVO) {
        logger.info("增加/修改企业客户分组信息");
        return RespGenerator.returnOK(enterpriseCustomerGroupService.modifyEnterpriseCustomerGroup(enterpriseCustomerGroupVO));
    }

    @ApiOperation(value = "删除企业客户分组")
    @PostMapping("/deleteEnterpriseCustomerGroup")
    @MyLog(systemFunctionName = "企业客户分组管理", systemFunctionUrl = "/enterpriseCustomerGroupController/deleteEnterpriseCustomerGroup", userOperationType = 3, userOperationSummary = "删除企业客户分组")
    public BaseResponse<Integer> deleteEnterpriseCustomerGroup(@RequestBody EnterpriseCustomerGroupVO enterpriseCustomerGroupVO) {
        logger.info("删除企业客户分组");
        return RespGenerator.returnOK(enterpriseCustomerGroupService.deleteEnterpriseCustomerGroup(enterpriseCustomerGroupVO));
    }

    @ApiOperation(value = "企业客户分组添加企业客户")
    @PostMapping("/insertGroupCustomer")
    @MyLog(systemFunctionName = "企业客户分组管理", systemFunctionUrl = "/enterpriseCustomerGroupController/insertGroupCustomer", userOperationType = 1, userOperationSummary = "企业客户分组添加企业客户")
    public BaseResponse<Integer> insertGroupCustomer(@RequestBody EnterpriseCustomerGroupVO enterpriseCustomerGroupVO) {
        logger.info("企业客户分组添加企业客户");
        return RespGenerator.returnOK(enterpriseCustomerGroupService.insertGroupCustomer(enterpriseCustomerGroupVO));
    }

    @ApiOperation(value = "企业客户分组移除企业客户")
    @PostMapping("/deleteGroupCustomer")
    @MyLog(systemFunctionName = "企业客户分组管理", systemFunctionUrl = "/enterpriseCustomerGroupController/deleteGroupCustomer", userOperationType = 3, userOperationSummary = "企业客户分组移除企业客户")
    public BaseResponse<Integer> deleteGroupCustomer(@RequestBody EnterpriseCustomerGroupVO enterpriseCustomerGroupVO) {
        logger.info("企业客户分组移除企业客户");
        return RespGenerator.returnOK(enterpriseCustomerGroupService.deleteGroupCustomer(enterpriseCustomerGroupVO));
    }

    @ApiOperation(value = "获取可添加的企业客户列表")
    @PostMapping("/getEnableAddCustomerList")
    @MyLog(systemFunctionName = "企业客户分组管理", systemFunctionUrl = "/enterpriseCustomerGroupController/getEnableAddCustomerList", userOperationType = 4, userOperationSummary = "获取可添加的企业客户列表")
    public BaseResponse<EnterpriseCustomerBO> getEnableAddCustomerList(@RequestBody EnterpriseCustomerVO enterpriseCustomerVO) {
        logger.info("获取可添加的企业客户列表信息");
        return RespGenerator.returnOK(enterpriseCustomerGroupService.getEnableAddCustomerList(enterpriseCustomerVO));
    }

}
